home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
LANG
/
C
/
LIB
/
UNIXLIB37B
/
!UnixLib37
/
src
/
signal
/
c
/
sigaction
< prev
next >
Wrap
Text File
|
1996-11-09
|
2KB
|
62 lines
/****************************************************************************
*
* $Source: /unixb/home/unixlib/source/unixlib37/src/signal/c/RCS/sigaction,v $
* $Date: 1996/10/30 22:04:51 $
* $Revision: 1.1 $
* $State: Rel $
* $Author: unixlib $
*
* $Log: sigaction,v $
* Revision 1.1 1996/10/30 22:04:51 unixlib
* Initial revision
*
***************************************************************************/
static const char rcs_id[] = "$Id: sigaction,v 1.1 1996/10/30 22:04:51 unixlib Rel $";
/* sigaction.c: Written by Nick Burrett, 31 August 1996. */
#include <errno.h>
#include <stddef.h>
#include <signal.h>
#include <unixlib/sigstate.h>
#include <sys/unix.h>
/* Set up a new action for the signal 'sig' specified by 'act'.
The old action is returned in 'oact'.
If oact is null, no information is returned.
If act is null, the signal action remains unchanged, you can then
read the action currently associated with the signal.
Returns zero on sucess, -1 on failure. */
int sigaction (int sig, const struct sigaction *act, struct sigaction *oact)
{
struct unixlib_sigstate *ss = &__u->sigstate;
if (sig <= 0 || sig >= NSIG || sig == SIGKILL || sig == SIGSTOP)
{
/* Signal number was out of range, or a SIGKILL or SIGSTOP
was trapped. */
errno = EINVAL;
return -1;
}
if (oact != NULL)
{
oact->sa_handler = ss->actions[sig].sa_handler;
oact->sa_mask = ss->actions[sig].sa_mask;
oact->sa_flags = ss->actions[sig].sa_flags;
}
if (act != NULL)
{
ss->actions[sig].sa_handler = act->sa_handler;
ss->actions[sig].sa_mask = act->sa_mask;
ss->actions[sig].sa_flags = act->sa_flags;
}
return 0;
}